<?php
C_base::yn_file('base'.DS.'adminbase.php');
class kfmain extends adminbase
{
	var $_vpath='kefu/';  //定义调用模板所属一级文件夹
	
	function __construct(){
		parent::__construct();
		$this->titl = '后台管理';
		$this->gnpd = '&gnid=83';
	}
	
	function index(){//登录
		
	}
	
	function welcome(){//我的桌面
		
	}
	
	function login(){//登录判断
		extract($this->_post());
		if(@$online){//设置COOKIE
			$this->cookie('online','1',7);
		}else{//删除
			$this->cookie('online','-1',-1);
		}
		$aa = C_base::M('kefu.fankui')->kfadmin_s(array('username'=>$username,'password'=>md5($passwd)));
		if($aa){
			if($aa['dongjie'] == 1){
				exit('-1');//管理员被锁定
			}
			$this->Ses('kf_id',$aa['id']);//登录id
			$this->Ses('kf_name',$aa['name']);//登录用户
			/* if($aa['sjid'] == 0){
				$qx = 0;
			}else{
				$r = C_base::M('kefu.xitonggl')->zu_s(array('id'=>$aa['zu']));
				$qx = explode(',',$r['qx']);
			}
			$this->Ses('kf_quanxian',$qx);//权限 */
			C_base::M('kefu.fankui')->kfadmin_u(array('id'=>$aa['id']),array('username'=>$username,'dltime'=>time()));
			$this->_alert_location($this->_url.'/kefu/?act=main');
		}else{
			$this->_alert_location($this->_url.'/kefu/?act=index','登录失败');
		}
	}
	
	function logout(){//退出
		$this->Ses('kf_id','');
		$this->Ses('kf_user','');
		$this->Ses('kf_quanxian','');
		$this->_alert_location($this->_url.'/kefu');
	}
	
	function main(){//后台管理中心
		$this->tit = '系统配置';
		$this->ksfdl();
		$this->rs = C_base::M('admin.base')->con_s();//读取网站设置
		$yuyan = array();
		if(@$this->_yuyan){
			foreach ($this->_yuyan as $k=>$v){
				$yuyan[] = $v['name'];//语言名称
			}
		}
		$this->rs['language'] = implode(',', $yuyan);//语言名称
	}
	
	function jianjie(){
		$this->tit = '思凯简介';
		$this->ksfdl();
		$this->rs = C_base::M('public')->con_s(array('qyjj','zyyw','hzjh','fwsm','bzzx','phone','email','firm','address'));
		$this->rs['qyjj'] = htmlspecialchars_decode($this->rs['qyjj']);
		$this->rs['zyyw'] = htmlspecialchars_decode($this->rs['zyyw']);
		$this->rs['hzjh'] = htmlspecialchars_decode($this->rs['hzjh']);
		$this->rs['fwsm'] = htmlspecialchars_decode($this->rs['fwsm']);
		$this->rs['bzzx'] = htmlspecialchars_decode($this->rs['bzzx']);
	}
	
	function jianjie_u(){
		extract($this->_post());
		$w = array();
		$u = array('qyjj'=>htmlspecialchars($qyjj),'zyyw'=>htmlspecialchars($zyyw),'hzjh'=>htmlspecialchars($hzjh),
				   'fwsm'=>htmlspecialchars($fwsm),'bzzx'=>htmlspecialchars($bzzx),'phone'=>$phone,'email'=>$email,
				   'firm'=>$firm,'address'=>$address);
		$r = C_base::M('public')->con_u($w,$u);
		if($r == '1'){
			exit('cg');
		}else{
			exit('error');
		}
	}
/*************路由开始*******************/
	function news(){//新闻系统
		$this->_is_html = 1;
		C_base::own('kefu.news');
	}
	
	function tuisong(){//推送系统
		$this->_is_html = 1;
		C_base::own('kefu.tuisong');
	}
	
	function fankui(){//反馈系统
		$this->_is_html = 1;
		C_base::own('kefu.fankui');
	}
	
	function user(){//用户系统
		$this->_is_html = 1;
		C_base::own('kefu.user');
	}
	
	function ltjl(){//聊天记录
		$this->_is_html = 1;
		C_base::own('kefu.ltjl');
	}
	
	function shenhe(){//审核
		$this->_is_html = 1;
		C_base::own('kefu.shenhe');
	}
}